package cn.wolfcode.mp.mapper;

import cn.wolfcode.mp.domain.Employee;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;


public interface EmployeeMapper extends BaseMapper<Employee> {

    List<Employee> listByXmlSingle();

    List<Employee> listByXmlJoin();

    //使用注解的方式,不写xml文件
    @Select("select e.* from t_employee e")
    List<Employee> listByAnnoSingle();


    //关联多表查询 不建议使用这种方式
    @Select("select e.*, d.id d_id, d.name d_name, d.sn d_sn from t_employee e left join department d on e.dept_id = d.id")
    @Results({
            @Result(column="d_id", property = "dept.id"),
            @Result(column="d_name", property = "dept.name"),
            @Result(column="d_sn", property = "dept.sn")
    })
    List<Employee> listByAnnoJoin();

}
